package com.sdut.material.controller;


import com.sdut.material.service.IRepositoryService;
import com.sdut.material.util.JSONResult;
import com.sdut.material.util.LayUITableResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author Yu
 * @since 2022-04-20
 */
@Controller
@RequestMapping("/repository")
public class RepositoryController {
    @Autowired
    private IRepositoryService repositoryService;
    @RequestMapping("/getRepositoryListPage")
    public String getRepositoryListPage() {
        return "repository/repository_list";
    }
    @RequestMapping("/selectByPage")
    @ResponseBody
    public LayUITableResult selectByPage(Long page,Long limit) {
        return repositoryService.selectByPage(page,limit);
    }
    @RequestMapping("/deleteById")
    @ResponseBody
    public JSONResult deleteById(Integer repositoryId) {
        repositoryService.deleteById(repositoryId);
        return JSONResult.ok("删除成功");
    }
    @RequestMapping("/deleteAll")
    @ResponseBody
    public JSONResult deleteAll(String ids) {
        String[] idArray = ids.split(",");
        for (String id : idArray) {
            deleteById(Integer.parseInt(id));
        }
        return JSONResult.ok("删除成功");
    }
}

